<template>
  <div class="main-content">
    <!-- 列表页 -->
    <div>
      <div class="table-content">
        <el-table class="tables" empty-text="暂未有导师接受" :size="contents.tableSize"
                  :show-header="contents.tableShowHeader"
                  :border="contents.tableBorder"
                  :fit="contents.tableFit"
                  :stripe="contents.tableStripe"
                  :style="{width: '100%',fontSize:contents.tableContentFontSize,color:contents.tableContentFontColor}"
                  :data="dataList"
                  @selection-change="">
          <el-table-column v-if="contents.tableSelection"
                           type="selection"
                           header-align="center"
                           align="center"
                           width="50">
          </el-table-column>

          <el-table-column label="序号" type="index" width="50"/>

          <el-table-column :sortable="contents.tableSortable" :align="contents.tableAlign"
                           prop="mentorname"
                           header-align="center"
                           label="姓名">
            <template v-slot:="scope">
              {{ scope.row.mentorname}}
            </template>
          </el-table-column>

          <el-table-column :sortable="contents.tableSortable" :align="contents.tableAlign"
                           prop="gender"
                           header-align="center"
                           label="性别">
            <template v-slot:="scope">
              {{ scope.row.gender}}
            </template>
          </el-table-column>

          <el-table-column :sortable="contents.tableSortable" :align="contents.tableAlign"
                           prop="studentcollege"
                           header-align="center"
                           label="学院">
            <template v-slot:="scope">
              {{ scope.row.mentorcollege}}
            </template>
          </el-table-column>
        </el-table>
      </div>
    </div>

  </div>
</template>
<script>
import {MessageBox} from "element-ui";

export default {
  data() {
    return {
      searchForm: {
        key: ""
      },

      user: [],

      dialogVisible: false,

      form: {},
      li: [],
      dataList: [],

      selectStudents: [],
      num: 0,


      pageIndex: 1,
      pageSize: 10,
      totalPage: 0,
      dataListLoading: false,
      dataListSelections: [],
      sfshVisiable: false,
      shForm: {},
      chartVisiable: false,
      addOrUpdateFlag: false,

      fileList: [],

      contents: {
        "searchBtnFontColor": "rgba(49,47,47,0.88)",
        "pagePosition": "1",
        "inputFontSize": "14px",
        "inputBorderRadius": "5px",
        "tableBtnDelFontColor": "#333",
        "searchBtnHeight": "40px",
        "inputIconColor": "#C0C4CC",
        "searchBtnBorderRadius": "5px",
        "tableStripe": false,
        "tableBtnDelBgColor": "rgba(214, 186, 232, 1)",
        "tableSize": "medium",
        "searchBtnBorderStyle": "solid",
        "tableSelection": true,
        "searchBtnBorderWidth": "1px",
        "tableContentFontSize": "14px",
        "searchBtnBgColor": "rgba(218,229,223,0.66)",
        "inputTitleSize": "16px",
        "pageJumper": true,
        "tableBtnDetailFontColor": "#333",
        "tableBtnHeight": "40px",
        "pagePager": true,
        "searchBtnBorderColor": "#DCDFE6",
        "tableHeaderFontColor": "rgba(47,44,44,0.76)",// 列首字体颜色
        "tableBtnBorderRadius": "5px",

        "btnAdAllDelFontColor": "#333",
        "btnAdAllWarnFontColor": "#ffffff",// 字体颜色
        "btnAdAllBorderColor": "#b2ac68",// 左上按钮边框颜色
        "btnAdAllHeight": "40px",
        "btnAdAllWarnBgColor": "rgba(75,222,146,0.8)",
        "btnAdAllFontWeight": 550,
        "btnAdAllBorderWidth": "1px",
        "btnAdAllAddBgColor": "rgba(75,222,146,0.8)",//背景颜色

        "tableStripeFontColor": "#606266",
        "tableBtnBorderStyle": "solid",
        "inputHeight": "40px",
        "btnAdAllBorderRadius": "5px",
        "btnAdAllDelBgColor": "rgba(255, 76, 10, 0.71)",
        "pagePrevNext": true,
        "searchBtnFont": "1",
        "tableIndex": true,
        "btnAdAllIcon": "1",
        "tableSortable": true,
        "pageSizes": true,
        "tableFit": true,
        "pageBtnBG": true,
        "searchBtnFontSize": "14px",
        "tableBtnEditBgColor": "rgba(202, 235, 202, 1)",
        "inputBorderWidth": "1px",
        "inputFontPosition": "2",
        "inputFontColor": "#333",
        "pageEachNum": 10,
        "tableHeaderBgColor": "rgb(255,255,255)",//列首背景
        "inputTitleColor": "rgba(54,55,58,0.88)",
        "btnAdAllBoxPosition": "1",
        "tableBtnDetailBgColor": "rgba(173, 241, 242, 1)",
        "inputIcon": "0",
        "searchBtnIconPosition": "1",
        "btnAdAllFontSize": "14px",
        "inputBorderStyle": "solid",
        "inputBgColor": "rgba(255,255,255,0.66)",
        "pageStyle": false,
        "pageTotal": true,
        "btnAdAllAddFontColor": "#333",
        "tableBtnFont": "1",
        "tableContentFontColor": "#29292f",//表格内字体
        "inputBorderColor": "#DCDFE6",
        "tableShowHeader": true,
        "tableBtnFontSize": "14px",
        "tableBtnBorderColor": "#DCDFE6",
        "inputIconPosition": "1",
        "tableBorder": true,
        "btnAdAllBorderStyle": "solid",
        "tableBtnBorderWidth": "1px",
        "tableStripeBgColor": "#F5F7FA",
        "tableBtnEditFontColor": "#333",
        "tableAlign": "center"
      },
      layouts: '',
    };
  },
  created() {
    this.init();
    this.contentStyleChange()
  },
  mounted() {
    this.getDataList();
  },

  methods: {
    /*组件设计方法*/
    contentStyleChange() {
      this.contentSearchStyleChange()
      this.contentBtnAdAllStyleChange()
      this.contentSearchBtnStyleChange()
      this.contentPageStyleChange()
    },
    contentSearchStyleChange() {
      this.$nextTick(() => {
        document.querySelectorAll('.form-content .slt .el-input__inner').forEach(el => {
          let textAlign = 'left'
          if (this.contents.inputFontPosition == 2) textAlign = 'center'
          if (this.contents.inputFontPosition == 3) textAlign = 'right'
          el.style.textAlign = textAlign
          el.style.height = this.contents.inputHeight
          el.style.lineHeight = this.contents.inputHeight
          el.style.color = this.contents.inputFontColor
          el.style.fontSize = this.contents.inputFontSize
          el.style.borderWidth = this.contents.inputBorderWidth
          el.style.borderStyle = this.contents.inputBorderStyle
          el.style.borderColor = this.contents.inputBorderColor
          el.style.borderRadius = this.contents.inputBorderRadius
          el.style.backgroundColor = this.contents.inputBgColor
        })
        if (this.contents.inputTitle) {
          document.querySelectorAll('.form-content .slt .el-form-item__label').forEach(el => {
            el.style.color = this.contents.inputTitleColor
            el.style.fontSize = this.contents.inputTitleSize
            el.style.lineHeight = this.contents.inputHeight
          })
        }
        setTimeout(() => {
          document.querySelectorAll('.form-content .slt .el-input__prefix').forEach(el => {
            el.style.color = this.contents.inputIconColor
            el.style.lineHeight = this.contents.inputHeight
          })
          document.querySelectorAll('.form-content .slt .el-input__suffix').forEach(el => {
            el.style.color = this.contents.inputIconColor
            el.style.lineHeight = this.contents.inputHeight
          })
          document.querySelectorAll('.form-content .slt .el-input__icon').forEach(el => {
            el.style.lineHeight = this.contents.inputHeight
          })
        }, 10)

      })
    },
    // 搜索按钮
    contentSearchBtnStyleChange() {
      this.$nextTick(() => {
        document.querySelectorAll('.form-content .slt .el-button--success').forEach(el => {
          el.style.height = this.contents.searchBtnHeight
          el.style.color = this.contents.searchBtnFontColor
          el.style.fontSize = this.contents.searchBtnFontSize
          el.style.borderWidth = this.contents.searchBtnBorderWidth
          el.style.borderStyle = this.contents.searchBtnBorderStyle
          el.style.borderColor = this.contents.searchBtnBorderColor
          el.style.borderRadius = this.contents.searchBtnBorderRadius
          el.style.backgroundColor = this.contents.searchBtnBgColor
        })
      })
    },
    // 新增、批量删除
    contentBtnAdAllStyleChange() {
      this.$nextTick(() => {
        document.querySelectorAll('.form-content .ad .el-button--success').forEach(el => {
          el.style.height = this.contents.btnAdAllHeight
          el.style.color = this.contents.btnAdAllAddFontColor
          el.style.fontSize = this.contents.btnAdAllFontSize
          el.style.borderWidth = this.contents.btnAdAllBorderWidth
          el.style.borderStyle = this.contents.btnAdAllBorderStyle
          el.style.borderColor = this.contents.btnAdAllBorderColor
          el.style.borderRadius = this.contents.btnAdAllBorderRadius
          el.style.backgroundColor = this.contents.btnAdAllAddBgColor
        })
        document.querySelectorAll('.form-content .ad .el-button--danger').forEach(el => {
          el.style.height = this.contents.btnAdAllHeight
          el.style.color = this.contents.btnAdAllDelFontColor
          el.style.fontSize = this.contents.btnAdAllFontSize
          el.style.borderWidth = this.contents.btnAdAllBorderWidth
          el.style.borderStyle = this.contents.btnAdAllBorderStyle
          el.style.borderColor = this.contents.btnAdAllBorderColor
          el.style.borderRadius = this.contents.btnAdAllBorderRadius
          el.style.backgroundColor = this.contents.btnAdAllDelBgColor
        })
        document.querySelectorAll('.form-content .ad .el-button--warning').forEach(el => {
          el.style.height = this.contents.btnAdAllHeight
          el.style.color = this.contents.btnAdAllAddBgColor
          el.style.fontSize = this.contents.btnAdAllFontSize
          el.style.borderWidth = this.contents.btnAdAllBorderWidth
          el.style.borderStyle = this.contents.btnAdAllBorderStyle
          el.style.borderColor = this.contents.btnAdAllBorderColor
          el.style.borderRadius = this.contents.btnAdAllBorderRadius
          el.style.backgroundColor = this.contents.btnAdAllWarnBgColor
        })
      })
    },

    // 分页
    contentPageStyleChange() {
      let arr = []

      if (this.contents.pageTotal) arr.push('total')
      if (this.contents.pageSizes) arr.push('sizes')
      if (this.contents.pagePrevNext) {
        arr.push('prev')
        if (this.contents.pagePager) arr.push('pager')
        arr.push('next')
      }
      if (this.contents.pageJumper) arr.push('jumper')
      this.layouts = arr.join()
      this.contents.pageEachNum = 10
    },

    init() {
      this.genderOptions = "男,女".split(',')
    },
    search() {
      this.pageIndex = 1;
      this.getDataList();
    },

    // 获取数据列表
    getDataList() {
      this.dataListLoading = true;

      this.$http({
        url: 'student/accepted-mentor',
        method: 'get',
      }).then(({data}) => {
        if (data) {
          if (data.data !== null){
            this.dataList.push(data.data);
          }
        } else {
          this.$message.error(data.message)
        }
      }).catch(error => {
        this.$message.error(error)// 打印错误信息
      });
    },
    // 每页数
    sizeChangeHandle(val) {
      this.pageSize = val;
      this.pageIndex = 1;
      this.getDataList();
    },
    // 当前页
    currentChangeHandle(val) {
      this.pageIndex = val;
      this.getDataList();
    },
    // 多选
    selectionChangeHandler(val) {
      this.dataListSelections = val;
    },
    //索引
    indexMethod(index) {
      return (Number(this.pageIndex) - 1) * Number(this.pageSize) + index + 1;
    },
  }
};
</script>
<style lang="scss" scoped>
.slt {
  margin: 0 !important;
  display: flex;
}

.ad {
  margin: 0 !important;
  display: flex;
}

.pages {
  & /deep/ el-pagination__sizes {
    & /deep/ el-input__inner {
      height: 22px;
      line-height: 22px;
    }
  }
}


.el-button + .el-button {
  margin: 0;
}

.dialog-content {
  display: flex;
  justify-content: center; /* 水平居中 */
  align-items: center; /* 垂直居中 */
  height: 60px; /* 可以根据需要调整高度 */
}

.dialog-footer {
  display: flex;
  justify-content: space-between; /* 让按钮分布在两侧 */
}

.tables {
  & /deep/ .el-button--success {
    height: 40px;
    color: #333;
    font-size: 14px;
    border-width: 1px;
    border-style: solid;
    border-color: #DCDFE6;
    border-radius: 20px;
    background-color: rgba(173, 241, 242, 1);
  }

  & /deep/ .el-button--primary {
    height: 40px;
    color: #333;
    font-size: 14px;
    border-width: 1px;
    border-style: solid;
    border-color: #DCDFE6;
    border-radius: 20px;
    background-color: rgba(202, 235, 202, 1);
  }

  & /deep/ .el-button--danger {
    height: 40px;
    color: #333;
    font-size: 14px;
    border-width: 1px;
    border-style: solid;
    border-color: #DCDFE6;
    border-radius: 20px;
    background-color: rgba(214, 186, 232, 1);
  }

  & /deep/ .el-button {
    margin: 4px;
  }
}

</style>
